package com.example.statistics.ui.yw

import com.example.statistics.R
import com.example.statistics.bean.yw.ProductSalesBean
import com.example.statistics.common.BaseLoadingListActivity
import com.example.statistics.ex.httpGet
import com.example.statistics.ex.onActionLongClicked
import com.example.statistics.net.UrlConfig
import com.jhj.slimadapter.SlimAdapter
import com.jhj.slimadapter.holder.ViewInjector

/**
 * 成品销售记录
 */
class ProductSalesListActivity : BaseLoadingListActivity<ProductSalesBean>() {

    override val title: String
        get() = "成品列表"

    override val url: String
        get() = UrlConfig.YW_PRODUCT_SALES_LIST

    override val itemLayoutRes: Int
        get() = R.layout.list_item_common_display

    override fun itemViewConvert(adapter: SlimAdapter, injector: ViewInjector, bean: ProductSalesBean, position: Int) {
        injector.text(R.id.tv_title, bean.customer)
            .text(R.id.tv_subtitle, "${bean.productBrand}${bean.productName}：${bean.salesNumber}件*${bean.salesPrice}")
            .onActionLongClicked("删除" to {
                httpGet<Any>(UrlConfig.YW_PRODUCT_SALES_DELETE, config = {
                    isShowDialog = true
                    listParams = listOf("id" to bean.ID)
                }) {
                    refresh()
                }
            })
    }


}